<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="estilo/style.css" />
	<script type="text/javascript" src="scripts/ajax.js" ></script>
	<script type="text/javascript" src="scripts/carga_ajax.js"></script>
	<script language="JavaScript" type="text/javascript">
	      
		 $.subscribe('validarX', function(event,data) {
		      var fData = event.originalEvent.formData;
		      var cod_v=document.getElementById('cod_vendedor_'+fData[0].value).value;
		      if( cod_v =='-1'){
		    	  var audioElement = document.createElement('audio');
		    	  audioElement.setAttribute('autobuffer', 'true');
				  audioElement.setAttribute('src', 'sonidos/a.ogg');
				  audioElement.play();
		    	  alert('Debe seleccionar el vendedor'); 
		    	  event.originalEvent.options.submit = false; 
		      }else{
		    	  //alert('Selecciono='+document.getElementById('cod_vendedor_'+fData[0].value).value);
		    	  event.originalEvent.options.submit = true; 
		      }
		   });
		  $.subscribe('okX', function(event,data) {
				 
				  var audioElement = document.createElement('audio');
		    	  audioElement.setAttribute('autobuffer', 'true');
				  audioElement.setAttribute('src', 'sonidos/i.ogg');
				  audioElement.play();
		   });
		  $.subscribe('errX', function(event,data) {
			 
			  var audioElement = document.createElement('audio');
	    	  audioElement.setAttribute('autobuffer', 'true');
			  audioElement.setAttribute('src', 'sonidos/e.ogg');
			  audioElement.play();
	   });
		
	 </script> 
</head>
  
<body>
<div id='sonidox' ></div>	
<div id='resultado_gd_aprxss' >
<table width="100%">
<tr Height='10px' >
			<td width='45%' class='tabla_th1' >Cliente</td>
			<td width='10%' class='tabla_th1' >Ciudad</td>
			<td width='10%' class='tabla_th1' >Zona</td>
		    <td width='15%' class='tabla_th1' >Vendedor</td>
		    <td width='10%' class='tabla_th1' >Accion</td>
</tr>
 <s:iterator var="outer2" status="i_status" value="rpt_lista" >
     <s:set name="n_cod"><s:property value="#outer2.codigo" /></s:set>
     <s:set name="n_stx"><s:property value="#outer2.status" /></s:set>
     <s:set name="n_tit"><s:property value="#outer2.tit_boton" /></s:set>
     <s:form action="asignar_cliente" id="form_guardar_asgcli_%{n_cod}" theme="simple" >	
        <s:hidden name='cod_cliente' id='cod_cliente_%{n_cod}'  value='%{n_cod}' ></s:hidden> 
        <s:hidden name='cli_status' id='cli_status_%{n_cod}'  value='%{n_stx}' ></s:hidden> 
	    <tr Height='10px'  >
		    <td width='45%' class='tit_td1'  >
			    <s:property value="#outer2.nombres" />
		    </td>
		    <td width='10%' class='tit_td1' >
		        <s:property value="#outer2.ciudad" />
		    </td>
		    <td width='10%' class='tit_td1' >
		        <s:property value="#outer2.zona" />
		    </td>
		    <td width='15%' class='tit_td1' >
		        <s:url id="remoteurl" action="cargar_vendedores_corp_cli" /> 
		      	<sj:select href="%{remoteurl}" name="cod_vendedor" id="cod_vendedor_%{n_cod}" headerKey="-1" headerValue="Seleccione" list="vendedores" indicator="progreso_" listKey='cod' listValue='descripcion' />
		    </td>
		    <td width='10%' class='tit_td1' >
		        <sj:div id='resultado_stx_ssx%{n_cod}' >  
			        <sj:submit  onBeforeTopics="validarX" onCompleteTopics="okX" onErrorTopics="errX" id='%{n_cod}' cssClass="boton_sia1" targets="resultado_stx_ssx%{n_cod}" indicator="indicatorc" button="true" value="%{n_tit}" theme="simple"  />
			    </sj:div>
		    </td>
	     </tr>
	 </s:form>  
</s:iterator>
 </table>
</div>
</body>
</html>
